package com.jade.zsy.base.facade.impl;

import com.jade.bss.DbException;
import com.jade.bss.base.utils.CopyBean;
import com.jade.bss.db.impl.BaseFacadeImpl;
import com.jade.framework.base.criterion.Criteria;
import com.jade.framework.base.util.PagingList;
import com.jade.framework.base.util.PagingResult;
import com.jade.zsy.base.dao.BusinessLogDao;
import com.jade.zsy.base.entity.BusinessLog;
import com.jade.zsy.base.facade.BusinessLogFacade;
import com.jade.zsy.base.vo.BusinessLogVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * 业务日志
 * User: jinya
 * Date: 2017/6/3
 * Time: 14:08
 * TEL :17701640710   MAIL:2009_jinya@163.com
 * To change this template use File | Settings | File Templates.
 */
@Service("BusinessLogFacade")
public class BusinessLogFacadeImpl extends BaseFacadeImpl  implements BusinessLogFacade {
    @Inject
    @Named("BusinessLogDao")
    private BusinessLogDao entityDao;
    @Override
    @Transactional
    public void save(Object obj) throws DbException {
        BusinessLog entity=(BusinessLog)obj;
        entity.setOwnerId("1");
        super.save(entity);
    }
    @Override
    public PagingResult queryEntity(Object obj, int page, int size, String keys, String... orders) throws DbException,IllegalAccessException, InstantiationException {
        BusinessLogVo entity=(BusinessLogVo)obj;
        Criteria criteria = new Criteria((page - 1) * size, size);

        PagingList pagingList = entityDao.queryEntity(BusinessLog.class, criteria);
        PagingResult  result = PagingResult.getResult(CopyBean.copy(pagingList, BusinessLogVo.class), pagingList.getTotalCount(), page, size);
        return result;
    }
}
